package com.smart.nine.spel.expr.literal;

import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;

/**
 * 文本字符解析
 *
 * @author junrui.wang
 * @create 2019/3/21
 */
public class LiteralExprSample {
    public static void main(String[] args) {
        ExpressionParser expressionParser = new SpelExpressionParser();
        //解析字符串
        String helloWorld = expressionParser.parseExpression("\"hello world\"").getValue(String.class);
        System.out.println(helloWorld);
        //解析双精度浮点型
        Double doubleNumber = expressionParser.parseExpression("6.123E+23").getValue(Double.class);
        System.out.println(doubleNumber);
        //解析整形
        Integer intMax = expressionParser.parseExpression("0x7FFFFFFF").getValue(Integer.class);
        System.out.println(intMax);
        //解析布尔值
        Boolean booleanValue = expressionParser.parseExpression("true").getValue(Boolean.class);
        System.out.println(booleanValue);
        //解析空值
        Object nullValue = expressionParser.parseExpression("null").getValue(Object.class);
        System.out.println(nullValue);
    }
}
